<?php
class StringTool {
	
	/**
	 * @var $value string|array|object
	 * @return string|array|object
	 */
	static public function escape($value) {
		if (is_array($value) || is_object($value)) {
			foreach($value as $key=>$value) 
				$value[$key] = self::cleanRequestVar($value);
		} else 
		if (is_string($value)) {
			if (ini_get('magic_quotes_gpc') == 0) 
				$value = mysql_escape_string($value); 
			$value = htmlspecialchars($value);
		}
		
		return $value;
	}
	
	/**
	 * @var $value string|array|object
	 * @return string|array|object
	 */
	static public function unescape($value) {
		if (is_array($value) || is_object($value)) {
			foreach($value as $key=>$value) 
				$value[$key] = self::openRequestVar($value);
		} else 
		if (is_string($value)) {
			$value = htmlspecialchars_decode($value);
			$value = stripslashes($value);
		}
		
		return $value;
	}
}
?>